package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.mapper.DtsTopicMapper;
import com.qf.pojo.DtsTopic;
import com.qf.service.DtsTopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author Zwnan
 */
@Service
public class DtsTopicServiceImpl implements DtsTopicService {

    @Autowired
    private DtsTopicMapper dtsTopicMapper;

    @Override
    public IPage<DtsTopic> findPage(Integer page, Integer limit, String sort, String order) {
        IPage<DtsTopic> iPage = new Page<>();

        return dtsTopicMapper.selectPage(iPage,new QueryWrapper<DtsTopic>().eq("deleted", false));
    }

    @Override
    public void insert(DtsTopic dtsTopic) {
        dtsTopicMapper.insert(dtsTopic);
    }

    @Override
    public void update(DtsTopic dtsTopic) {
        dtsTopicMapper.updateById(dtsTopic);
    }

    @Override
    public void delete(DtsTopic dtsTopic) {
        dtsTopic.setDeleted(true);
        dtsTopicMapper.updateById(dtsTopic);
    }
}
